package com.zxc.ompz;
/**
 * Implement this interface and add your implementation using
 * MediaStreamPlayer.addMediaStreamPlayerListener(MediaStreamPlayerListener)
 * to receive events of the MediaStreamPlayer instance.
 * 
 * @author ZXC (zhang.jianchun1@gmail.com)
 *
 */
public interface MediaStreamPlayerListener {
	public static final String USER_SEEK_OK = "USER_SEEK_OK";
	public static final String CONNECTION_OPEN = "connection open";
	public static final String CONNECTION_CLOSE = "connection close";
	public static final String CONNECTION_FAIL = "connection fail";
	public static final String BUFFER_EMPTY = "buffer empty";
	public static final String BUFFER_FULL = "buffer full";
	public static final String DOWNLOAD_OK = "download ok";
	/**
	 * Output log to listener with related log level:
	 * 0: Informational
	 * 3: Debuging
	 * 6: Error
	 * 7: Exception
	 * 
	 * @param level	the level of log event
	 * @param msg	the log message
	 */
	public void playerLog(int level, String msg);
	/**
	 * This method is invoked when the underlying Player's 
	 * PLayerListener.playerUpdate(Player player, String event, Object eventData)
	 * is called. 
	 * 
	 * @param event	The event generated as defined by the enumerated types.
	 * @param eventData	The associated event data.
	 */
	public void playerUpdate(String event, Object eventData);
	/**
	 * Invoked when the contentLength is available or is updated.
	 * @param contentLength	new contentLength.
	 */
	public void contentLengthUpdated(long contentLength);
	
	/**
	 * Invoked when the current position of the player is updated in terms of bytes.
	 * Current position of the player does not represent what's currently playing but 
	 * what the player is currently reading. 
	 *  
	 * @param now Current position of the player's read pointer. Between 0 and 
	 * content-length.
	 */
	public void updateBufferPosition(long[] positions);
	
	/**
	 * A convenient event to get notified where the playback is now. 
	 * The implementation simply uses getMediaTime on the underlying player 
	 * to get this information.
	 * 
	 * @param now	Current position of the playback in microseconds.
	 */
	public void updatePlayingPosition(long now);
}
